#pragma once

#include <event2/event.h>
#include <list>
#include <mutex>

class XTask;

class XThread
{
public:
	void start();
	void main();
	bool setup();
	void notify(evutil_socket_t fd, short which);
	void activate();
	void addTask(XTask *task);
	XThread();
	~XThread();
	int mId = 0;

private:
	evutil_socket_t mNotifySendFd = 0;
	struct event_base *mEventBase = nullptr;
	std::list<XTask *> mTaskQueue;
    std::mutex mMutex;
};

